/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ai;

import java.util.Random;

/**
 *
 * @author pjl
 */
public class Util {

   

    public static int toLabel(float a[]) {
        
        int lab=-1;
        float val=Float.NEGATIVE_INFINITY;
        for (int i=0 ; i<a.length ; i++) {
            if ( a[i]> val ) {
                lab=i;
                val=a[i];
            }
        }
        return lab;
    }
    
    
    static float labs[][];
    static int nLabels=10;
    
    static {
        labs=new float[nLabels][];
        
        for(int i=0;i<10;i++){
            labs[i]=new float[10];
            labs[i][i]=1.0f;
        }
        
    }
    
    public static float[] fromLabel(int lab) {
         return labs[lab];
    }
       //	sigmoid function
    public static float sigmoid(float in) {
        return (float) (1.0 / (1.0 + Math.exp(-in)));
    }

    static Random createRandom() {
        return new Random(0L);
    }
    
 
    
}
